<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			#progess {
				height: 33px;
				width: 100%;
				background: gray;
			}
			
			#bar {
				width: 1%;
				height: 33px;
				background: green;
			}
		</style>
	</head>

	<body>
		<div id="progess">
			<div id="bar"></div>
		</div>
		<br />
		<button id="btn">点击</button>
		<script type="text/javascript">
			var btn = document.getElementById('btn');
			var bar = document.getElementById('bar')
			btn.onclick = function() {
				var timer = setInterval(myfun, 30);
				var width = 1;

				function myfun() {
					if(width >= 100) {
						clearInterval(timer);
					} else {
						width = width + 1;
						bar.style.width = width + '%';
					}
				}
			}
		</script>
	</body>

</html>